<%@page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%>
<%@include file="/includes/taglibs.jsp"%>
<%@page import="com.feib.soeasy.util.UserUtil"%>
<%@page import="java.util.Map"%>
<%@page import="com.feib.soeasy.util.CodeTableUtil"%>
<%@page import="com.feib.soeasy.action.Soez5001ActionBean"%>	

<c:choose>
	<c:when test="${null != actionBean.feedbackLog }">

<div id="feedbackLogViewDiv">
	<table id="paymentListTable">
		<tr>
		    <td colspan="6" class="paymentHeader">
			<c:out value="${actionBean.feedbackLog.PAYMENT_NAME}"/>
			</td>
		</tr>
		<tr>
			<th>繳費帳號</th>
			<td align="right"><c:out value="${actionBean.feedbackLog.USERNO}"/></td>								
			<c:choose>
				<c:when test="${actionBean.feedbackLog.GROUP_TYPE == 2 }">
					<th>學號</th>
					<td align="right"><c:out value="${actionBean.feedbackLog.STUDENT_ID}"/></td>
				</c:when>
				<c:otherwise>
					<th>客戶編號</th>
					<td align="right"><c:out value="${actionBean.feedbackLog.PAYER_ID}"/></td>
				</c:otherwise>
			</c:choose>
			
			<th>姓名</th>
			<td align="right"><c:out value="${actionBean.feedbackLog.PAYER_NAME}"/></td>
		</tr>
		<tr>
			<th>異常原因</th>
			<td align="left" colspan="2">
				<c:out value="${actionBean.feedbackLog.ERR_MSG}"/>
				<c:if test="${ 5== actionBean.feedbackLog.PAYMENT_STATUS }">(已有銷帳紀錄)</c:if>
				<c:if test="${ 4== actionBean.feedbackLog.PAYMENT_STATUS }">(已註銷)</c:if>
				<c:if test="${ 3== actionBean.feedbackLog.PAYMENT_STATUS }">(註銷中，不能銷帳)</c:if>
			</td>
		
			
	
			<th>繳款通路</th>
			<td align="left" colspan="2" >
			<%
			Soez5001ActionBean actionBean = (Soez5001ActionBean)request.getAttribute("actionBean");
			Map<String, Object> payment = actionBean.getFeedbackLog();
			String channel = (String)payment.get("FEEDBACK_CHANNEL");
			if (null != channel)
			{
			    if ("7111111".equalsIgnoreCase(channel))
			        channel = "D";
			    else if ("TFM".equalsIgnoreCase(channel))
			        channel = "E";
			    else if ("HILIFE".equalsIgnoreCase(channel))
			        channel = "F";
			    else if ("OKCVS".equalsIgnoreCase(channel))
			        channel = "G";
			    else if ("POST".equalsIgnoreCase(channel))
			        channel = "H";
			    else if ("ACH".equalsIgnoreCase(channel))
			        channel = "I";
			}
			    out.println(CodeTableUtil.getInstance().getCodeName(CodeTableUtil.CODE_KIND_CHANNEL, channel));
			%>
			</td>
			
		　</tr>
		  <tr>	
			<th>繳款截止日</th>
			<td align="right"><fmt:formatDate value="${actionBean.feedbackLog.PAY_DUE}" pattern="yyyy/MM/dd"  /></td>
			<th>繳款交易日</th>
			<fmt:parseDate var="aday" pattern="yyyyMMdd" value="${actionBean.feedbackLog.ADAY }" />
			<td align="center"><fmt:formatDate value="${aday}" pattern="yyyy/MM/dd"  /></td>
			<th>繳款核銷日</th>
			<td align="center"><fmt:formatDate value="${actionBean.feedbackLog.FBTIME}" pattern="yyyy/MM/dd"  /></td>
		</tr>
	    <tr>
	    	<c:choose>
				<c:when test="${actionBean.feedbackLog.GROUP_TYPE == 2 }">
					<c:choose>
						<c:when test="${actionBean.feedbackLog.TXAMT == actionBean.feedbackLog.TOTAL_LOANABLE_AMOUNT }">
		<tr>
			<th>應繳金額1</th>
			<td align="right"><fmt:formatNumber value="${actionBean.feedbackLog.TOTAL_AMOUNT}" pattern="##,###" /></td>
			<th>實繳金額1</th>
			<td align="right">0</td>
			<th>應退補差額1</th>
			<td align="right">0</td>
		</tr>
		<tr>
			<th>應繳金額2</th>
			<td align="right"><fmt:formatNumber value="${actionBean.feedbackLog.TOTAL_LOANABLE_AMOUNT}" pattern="##,###" /></td>
			<th>實繳金額2</th>
			<td align="right"><fmt:formatNumber value="${actionBean.feedbackLog.TXAMT}" pattern="##,###" /></td>
			<th>應退補差額2</th>
			<td align="right"><fmt:formatNumber value="${actionBean.feedbackLog.TXAMT - actionBean.feedbackLog.TOTAL_LOANABLE_AMOUNT}" pattern="##,###" /></td>
		</tr>
						</c:when>
						<c:otherwise>
		<tr>
			<th>應繳金額1</th>
			<td align="right"><fmt:formatNumber value="${actionBean.feedbackLog.TOTAL_AMOUNT}" pattern="##,###" /></td>
			<th>實繳金額1</th>
			<td align="right"><fmt:formatNumber value="${actionBean.feedbackLog.TXAMT}" pattern="##,###" /></td>
			<th>應退補差額1</th>
			<td align="right"><fmt:formatNumber value="${actionBean.feedbackLog.TXAMT - actionBean.feedbackLog.TOTAL_AMOUNT}" pattern="##,###" /></td>
		</tr>
		<tr>
			<th>應繳金額2</th>
			<td align="right"><fmt:formatNumber value="${actionBean.feedbackLog.TOTAL_LOANABLE_AMOUNT}" pattern="##,###" /></td>
			<th>實繳金額2</th>
			<td align="right">0</td>
			<th>應退補差額2</th>
			<td align="right">0</td>
		</tr>
						</c:otherwise>
					</c:choose>
				</c:when>
				
				<c:otherwise>
		<tr>
			<th>應繳金額1</th>
			<td align="right"><fmt:formatNumber value="${actionBean.feedbackLog.TOTAL_AMOUNT}" pattern="##,###" /></td>
			<th>實繳金額1</th>
			<td align="right"><fmt:formatNumber value="${actionBean.feedbackLog.TXAMT}" pattern="##,###" /></td>
			<th>應退補差額1</th>
			<td align="right"><fmt:formatNumber value="${actionBean.feedbackLog.TXAMT - actionBean.feedbackLog.TOTAL_AMOUNT}" pattern="##,###" /></td>
	    </tr>
				</c:otherwise>
			</c:choose>
	    	    
	    <tr>
	    	<td colspan="6" align="center">
	    		<c:if test="${null != actionBean.feedbackLog.PAYMENT_PK && 2 == actionBean.feedbackLog.PAYMENT_STATUS }">
	    		<input type="button" id="toWriteOffPaymentBtn" value="銷帳"/>
	    		</c:if>	    		
	    		<input type="button" id="toSkipFeedbackLogBtn" value="已處理"/>
	    		<input type="button" id="exitViewFeedbackLogBtn" value="離開"/>
	    		<input type="hidden" id="hidden7.paymentPk" value="<c:out value='${actionBean.feedbackLog.PAYMENT_PK}'/>" />
	    		<input type="hidden" id="hidden7.uid" value="<c:out value='${actionBean.feedbackLog.UID}'/>" />
	    	</td>
	    </tr>
	</table>
</div>

<script type="text/javascript">	
	<!--
	$(document).ready(function() {
		
		
		$( "#toWriteOffPaymentBtn").click(function() {
			$( "#spanReason" ).html('銷帳原因');
			$('#reason').val('');
			$('#hidden6\\.paymentPk').val($('#hidden7\\.paymentPk').val());
			$('#hidden6\\.feedbackUid').val($('#hidden7\\.uid').val());
			$( "#method6" ).attr('name', 'doWriteOffPayment');
			$( "#feedbackLogReasonDiv" ).dialog({  title:'請輸入銷帳原因' ,width: 400, resizable: false, modal: true  });
		});
		
		$( "#toSkipFeedbackLogBtn").click(function() {
			$( "#spanReason" ).html('處理原因');
			$('#reason').val('');
			$('#hidden6\\.paymentPk').val($('#hidden7\\.paymentPk').val());
			$('#hidden6\\.feedbackUid').val($('#hidden7\\.uid').val());
			$( "#method6" ).attr('name', 'doSkipFeedbackLog');
			$( "#feedbackLogReasonDiv" ).dialog({  title:'請輸入處理原因' ,width: 400, resizable: false, modal: true  });			
		});
		
		$( "#exitViewFeedbackLogBtn" ).click(function() {
			$("#feedbackLogDiv" ).dialog( "close" );
		});
	});
	//-->
</script>

<div id="cancelPaymentMsgDiv" style="display: none; ">
</div>
		

	</c:when>
	<c:otherwise>
		<div id="queryNothingBlockDiv" style="display: none;">
			查無資料
		</div>	
		<script type="text/javascript">
		<!--
		$(document).ready(function() {
			$( "#paymentsItemDiv" ).dialog( "destroy" );
			$( "#paymentsItemDiv" ).dialog({  title:'繳費單資料' ,width: 600, resizable: false, modal: true  });
		});
		//-->
		</script>
	</c:otherwise>
</c:choose>